export default {
  name: 'KTableColumn',
  componentName: 'KTableColumn',
  props: {
    prop: String,
    label: String,
    sortable: Boolean,
  },
  data() {
    return {
      column: {},
    }
  },
  render() {
  },
  watch: {
    prop(val) {
      this.column.prop = val
    },
    label(val) {
      this.column.lable = val
    },
    sortable(val) {
      this.column.sortable = val
    },
  },
  created() {
    let column = {
      ...this.$props,
    }
    let self = this
    column.renderCell = function (h, data) {
      let render = (h, data) => {
        return data.row[column.prop]
      }
// ⾃定义列模板
      if (self.$scopedSlots.default) {
        render = () => self.$scopedSlots.default(data)
      }
// 返回渲染内容
      return <div>{render(h, data)}</div>
    }
    this.column = column
  },
  mounted() {
    this.$parent.columns.push(this.column)
  },
}
